<template>
	<view>
		<tn-nav-bar fixed :bottomShadow="false">立即提现</tn-nav-bar>
		
		<view class="tn-classify__wrap" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<text class="title">兑换现金</text>
			<view class="list">
				<view class="item" v-for="(item,index) in list" :key="index" :class="{active: currentIndex == index}"
				@click="currentIndex = index">
					<text>{{item.txje}}</text>
					<text>元</text>
				</view>
			</view>
			<view class="way">
				<view class="item">
					<view class="left">
						<image src="../static/wxicon.png" mode="widthFix"></image>
						<text>提现到微信</text>
					</view>
					<view class="right">
						<image src="../static/checked.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="footer" @click="submit">
			<text>立即提现</text>
		</view>
	</view>
</template>

<script>
	
import Tools from '@/tools/config.js'
import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
export default {
	mixins: [template_page_mixin],
	data(){
		return{
			list:[],
			currentIndex: 0
		}
	},
	onShow(){
		this.initData()
	},
	methods:{
		submit(){
			let theopenid = uni.getStorageSync('openid')
			let theunionid = uni.getStorageSync('unionid')
			uni.request({
				url: Tools.host + '/wshly.ashx',
				method: 'POST',
				data: {
					'lx': 'my_ljtx',
					'openid': theopenid,
					'unionid': theunionid,
					'txjeid': this.list[this.currentIndex].txjeid,
					'txje': this.list[this.currentIndex].txje
				},
				success: (res) => {
					//成功
					if (res.data.return_code == 1) {
						uni.showToast({
							title:"提现成功",
							icon:"success"
						})
						setTimeout(()=>{
							this.goBack()
						},1500)
					}else{
						uni.showToast({
							title: res.data.return_msg,
							icon:"none"
						})
					}
				},
				fail: (res) => {
					console.log('失败' + res)
				}
			});
		},
		initData(){
			let theopenid = uni.getStorageSync('openid')
			let theunionid = uni.getStorageSync('unionid')
			uni.request({
				url: Tools.host + '/wshly.ashx',
				method: 'POST',
				data: {
					'lx': 'my_txcsh',
					'openid': theopenid,
					'unionid': theunionid,
				},
				success: (res) => {
					//成功
					if (res.data.return_code == 1) {
						var thejson = JSON.parse(res.data.data)
						this.list = thejson
						console.log(this.list)
					}
				},
				fail: (res) => {
					console.log('失败' + res)
				}
			});
		},
	}
}	

</script>

<style lang="scss" scoped>
	
.title{
	padding: 20rpx 30rpx;
	font-size: 30rpx;
	font-weight: 500;
}
	
.list{
	padding: 0 30rpx;
	display:flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: space-between;
	margin-top: 20rpx;
	.item{
		width:calc(100% / 3 - 15rpx);
		height: 200rpx;
		display:flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
		border-radius:24rpx;
		background-color: white;
		box-shadow: 0px 0px 12rpx rgba(0,0,0,.5);
		text:nth-child(1){
			font-size: 48rpx;
			font-weight: 600;
		}
		text:nth-child(2){
			font-size: 28rpx;
			margin-left: 4rpx;
			margin-top: 10rpx;
		}
	}
	.active{
		border: 2rpx solid $tn-color-orangered;
		text{
			color:$tn-color-orangered;
		}
	}
}	
.way{
	margin-top:20rpx;
	display:flex;
	flex-direction: column;
	padding: 0 30rpx;
	.item{
		border-radius: 16rpx;
		box-shadow: 0px 0px 12rpx rgba(0,0,0,.5);
		display:flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 20rpx;
		height: 120rpx;
		.left{
			display:flex;
			flex-direction: row;
			align-items: center;
			justify-content: flex-start;
			image{
				width: 60rpx;
				height: 60rpx;
			}
			text{
				margin-left: 10rpx;
			}
		}
		.right{
			image{
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
}

.footer{
	display:flex;
	align-items: center;
	justify-content: center;
	position:fixed;
	bottom: 70rpx;
	left:0;
	right: 0;
	text{
		width: 80%;
		height: 88rpx;
		display:flex;
		align-items: center;
		justify-content: center;
		background-color: $tn-color-orangered;
		color: white;
		font-size: 28rpx;
		border-radius: 16rpx;
	}
}
	

</style>